home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / tchrt3.zip / TESTBIOS.C < prev    next >
Text File  |  1990-07-23  |  6KB  |  164 lines

  1. /*---------------------------------------------------------------------------
  2.  |  Program TESTBIOS.C                                                      |
  3.  |                                                                          |
  4.  |  This program demonstrates the BIOS interrupt timing functionality of    |
  5.  |  TCHRT V3.  The user may select from several BIOS interrupts to          |
  6.  |  "exercise", and appropriate activity is generated.  A BIOS interrupt    |
  7.  |  timer summary is then produced.  MSDOS interrupt 21h is timed in all    |
  8.  |  cases, which will show the user the relationship between operating      |
  9.  |  system and hardware activity.                                           |
  10.  |                                                                          |
  11.  |  (c) 1989 Ryle Design, P.O. Box 22, Mt. Pleasant, MI 48804               |
  12.  |                                                                          |
  13.  |  V3.00  Turbo C Shareware Evaluation Version                             |
  14.  ---------------------------------------------------------------------------*/
  15.  
  16. #include <stdio.h>
  17. #include <process.h>
  18. #include <conio.h>
  19.  
  20. #include "pchrt.h"
  21.  
  22.  
  23. void do_crt(void)
  24. /*---------------------------------------------------------------------------
  25.  |  This function enables both CRT & MSDOS interrupt timing, generates some |
  26.  |  CRT activity, and displays the BIOS timer report.                       |
  27.  |                                                                          |
  28.  |  Globals referenced: none                                                |
  29.  |                                                                          |
  30.  |  Arguments: void                                                         |
  31.  |                                                                          |
  32.  |  Returns  : void                                                         |
  33.  ---------------------------------------------------------------------------*/
  34. {
  35.     int     indx;
  36.  
  37.     t_bios_start(CRT10+DOS21);
  38.  
  39.     for (indx=0; indx<10; indx++) printf("Ryle Design ... Purveyors of Big Science\n");
  40.  
  41.     t_bios_report(0);
  42.  
  43.     t_bios_stop();
  44.  
  45. } /* do_crt */
  46.  
  47.  
  48. void do_disk(void)
  49. /*---------------------------------------------------------------------------
  50.  |  This function enables both DISK & MSDOS interrupt timing, generates some|
  51.  |  DISK activity, and displays the BIOS timer report.                      |
  52.  |                                                                          |
  53.  |  Globals referenced: none                                                |
  54.  |                                                                          |
  55.  |  Arguments: void                                                         |
  56.  |                                                                          |
  57.  |  Returns  : void                                                         |
  58.  ---------------------------------------------------------------------------*/
  59. {
  60.     int     indx;
  61.     FILE    *tfile;
  62.  
  63.  
  64.     t_bios_start(DISK+DOS21);
  65.  
  66.     printf("Creating data file ... ");
  67.     tfile = fopen("TEST.XXX","wb");
  68.     printf("complete\n");
  69.  
  70.     printf("Writing 32k bytes two bytes at a time ... ");
  71.     for (indx=0; indx<16384; indx++) fwrite((int *)indx,1,sizeof(int),tfile);
  72.     printf("complete.\n");
  73.  
  74.     printf("Closing and erasing file ... ");
  75.     fclose(tfile);
  76.     unlink("TEST.XXX");
  77.     printf("complete.\n");
  78.  
  79.     t_bios_report(0);
  80.  
  81.     t_bios_stop();
  82.  
  83. } /* do_disk */
  84.  
  85.  
  86. void do_printer(void)
  87. /*---------------------------------------------------------------------------
  88.  |  This function enables both PRT & MSDOS interrupt timing, generates some |
  89.  |  printer activity, and displays the BIOS timer report.                   |
  90.  |                                                                          |
  91.  |  Globals referenced: none                                                |
  92.  |                                                                          |
  93.  |  Arguments: void                                                         |
  94.  |                                                                          |
  95.  |  Returns  : void                                                         |
  96.  ---------------------------------------------------------------------------*/
  97. {
  98.     int     indx;
  99.     FILE    *pfile;
  100.  
  101.     printf("Make sure printer is online and ready.  Press any key to continue >> ");
  102.     getch();
  103.  
  104.     t_bios_start(PRT+DOS21);
  105.  
  106.     pfile = fopen("PRN","wt");
  107.  
  108.     for (indx=0; indx<10; indx++) fprintf(pfile,"Ryle Design ... Purveyors of Big Science\n");
  109.  
  110.     fclose(pfile);
  111.  
  112.     t_bios_report(0);
  113.  
  114.     t_bios_stop();
  115.  
  116. } /* do_printer */
  117.  
  118.  
  119. void main(void)
  120. {
  121.     int             indx;
  122.     long unsigned   hits,elapsed;
  123.     char            ts[13];
  124.     
  125.     if (t_start() != TRUE)
  126.     {
  127.         printf("Insufficient heap for TCHRT operation\n");
  128.         exit(0);
  129.     }
  130.  
  131.     t_entry(0);
  132.  
  133.     printf("TESTBIOS - TCHRT V3 Demonstration Series\n\n");
  134.     printf("Make sure files 10.INT, 13.INT, 17.INT, and 21.INT are in this directory\n\n");
  135.  
  136.     do
  137.     {
  138.         printf("0 ... Profile BIOS interrupt 10h (CRT)\n");
  139.         printf("1 ... Profile BIOS interrupt 13h (Disk)\n");
  140.         printf("2 ... Profile BIOS interrupt 17h (Printer)\n");
  141.         printf("3 ... Exit\n");
  142.  
  143.         printf("Select 0-3 >> ");
  144.         indx = getche();
  145.         indx -= '0';
  146.         printf("\n");
  147.  
  148.         switch (indx)
  149.         {
  150.             case 0 :    do_crt();         break;
  151.             case 1 :    do_disk();       break;
  152.             case 2 :    do_printer();    break;
  153.         }
  154.     }
  155.     while (indx != 3);
  156.  
  157.     t_exit(0);
  158.     t_ask_timer(0,&hits,&elapsed);
  159.     t_stop();
  160.  
  161.     printf("TestBios complete.  Elapsed time %s\n",t_cvt_time(elapsed,ts) );
  162.  
  163. } /* TestBios */
  164.